<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">

<head>
  <title>
    <!--智能监控查询-->
  </title>
  <meta charset="utf-8">
  <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  <link rel="stylesheet" href="css/project/ui-res-v3.css">
  <link rel="stylesheet" href="css/project/ui-input-v3.css">
  <link rel="stylesheet" href="css/project/ui-color-v3.css">
  <link rel="stylesheet" href="css/project/style.css">
  <link rel="stylesheet" href="css/ui-base.css">
  <link rel="stylesheet" href="css/ui-box.css">
  <link rel="stylesheet" href="css/zv_common.css">
  <script src="js/jquery-3.1.1.min.js"></script>
  <script src="js/zy_control.js"></script>
  <script src="js/zy_click.js"></script>
  <!-- <script src="js/zy_json.js"></script> -->
  <script src="js/jquery.xml2json.js"></script>
  <script src="js/main.js?v=123518"></script>
  <script src="js/init.js"></script>
  <script src="js/JsonSQL/jsonsql-0.1.js"></script>
</head>

<body class="um-vp nobg " ontouchstart>
  <div id="page_1" class="ub ub-ver um-vp">
    <div class="ub ub-ver ">
      <div class="fline  c-wh">
        <div class="ub t-bla ub-ac umar-t nobg">
          <div class="ulim umw4 umar-r">中心名称</div>
          <div class="ub-f1 ub uba  b-gra  sel noboder">
            <div class="ub-f1 ut-s uinn tx-l t-gra ulh-sel" id="SiteName_default">请选择中心名称</div>
            <div class="b-gra  umw2 ub ub-pc ub-ac">
              <div class="ub-img umw1 umh1 res3"></div>
            </div>
            <select name="SiteName" selectedindex="0" id="SiteName" onchange="zv_linkageX(this.id,'zv_default','SiteID','请选择中心名称','<option value=0>请选择中心名称</option>')">

            </select>
          </div>
        </div>
      </div>
      <!--中心名称 end-->
      <div class="fline  c-wh">
        <div class="ub t-bla ub-ac umar-t nobg">
          <div class="ulim umw4 umar-r">站点名称</div>
          <div class="ub-f1 ub uba  b-gra  sel noboder">
            <div class="ub-f1 ut-s uinn tx-l t-gra ulh-sel" id="zv_default">请选择站点名称</div>
            <div class="b-gra  umw2 ub ub-pc ub-ac">
              <div class="ub-img umw1 umh1 res3"></div>
            </div>
            <select name="SiteID" selectedindex="0" id="SiteID" onchange="zy_selectmenu(this.id)">

	         </select>
          </div>
        </div>
      </div>
      <!--站点名称 end-->
      <div class="fline c-wh">
        <div class='ub umar-t ub-ac'>
          <div class=" ub-ac　ulim ulev0 umw4" style="height:2em; line-height:2em">监控起始日期</div>
          <div class="ub ub-f1 uba ub-ac b-bla b-norarea   noboder nobg">
            <div class="ub-f1 ut-s uinn   tx-l t-gra ulh-sel " id="PeriodStart" style="width:100%;padding-left:0.8em; padding-right:0.5em" onclick="checked_day_time('PeriodStart')">请选择监控日期</div>
          </div>
        </div>
      </div>
      <!--起始日期结束-->
      <div class="fline c-wh">
        <div class='ub umar-t ub-ac'>
          <div class=" ub-ac　ulim ulev0 umw4" style="height:2em; line-height:2em">监控结束日期</div>
          <div class="ub ub-f1 uba ub-ac b-bla b-norarea   noboder nobg">
            <div class="ub-f1 ut-s uinn   tx-l t-gra ulh-sel " id="PeriodEnd" style="width:100%;padding-left:0.8em; padding-right:0.5em" onclick="checked_day_time('PeriodEnd')">请选择监控日期</div>
          </div>
        </div>
      </div>
      <div class="fline   c-wh">
        <div class="ub ulab ub-ac umh1 umar-t ">
          <div class="umw4 ">区域视图</div>
          <div class="uba ub-f1 b-bla uc-a1 noboder nobg">
            <div class="ub-f1 ub uba  b-gra  sel noboder" onClick="OpenArea()">
              <div class="ub-f1 ut-s uinn tx-l t-gra ulh-sel" style="margin-left:0.3em;" id="area_selected">请选择区域</div>
              <div class="b-gra  umw2 ub">
                <div class="ub-img umw2" style="background:url(images/search.png) no-repeat; background-size:80%; margin-top:0.4em;"></div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div ontouchstart="zy_touch('zv-btn-act')" class="zvbtn  c-blu1  t-wh tx-c uc-a1 zvbtnpadding" style=" z-index:1000" onclick="LoadDataS()">确 定</div>
    </div>
    <input type="hidden" id="area" value="">
  </div>
  <div class="logobg" style="z-index:-1"><img src="images/logobg.png" width="80%"></div>
</body>
<script>
  zy_init();

  localStorage.setItem("AllSelectqiaowei", "0") //全部取消
  var now = getNowFormatDateTime()
  $$("PeriodStart").innerHTML = zv_detailed(zv_transdate(now) - 8 * 60 * 60).substring(0, zv_detailed(zv_transdate(now) - 8 * 60 * 60).length - 3);
  $$("PeriodEnd").innerHTML = getNowFormatDateTime();
  //var backup_PeriodStart_znjk= localStorage.getItem("backup_PeriodStart_znjk")
  //if(backup_PeriodStart_znjk!='null' && backup_PeriodStart_znjk!=null && backup_PeriodStart_znjk!='' &&backup_PeriodStart_znjk!=undefined)
  //{
  //	$$("PeriodStart").innerHTML =backup_PeriodStart_znjk;
  //}
  //var area_id=localStorage.getItem("area_id");//////////////////默认桥位
  //if(area_id != '' && area_id != 'undefined' && area_id != undefined)
  //{
  //	$$("area").value = area_id;
  //	var aearArrs = area_id.split(";");
  //	var len = aearArrs.length;
  //	$$("area_selected").innerHTML = "共选择了"+len+"个区域";
  //}
  function zv_SelectAreaSet() {
    var area = $$("area").value;
    //alert(area);
    //alert("zv_SelectAreaSet:"+area);
    localStorage.setItem("zv_SelectArea", area);
  }

  function removeItemSX(par) {
    var area = $$("area").value;
    var areax = ";" + area + ";";
    var aearArr = par.split("/");
    for (var i = 0; i < aearArr.length; i++) {
      ueppscript("intelligent_monitoring_area_hqT1", "content", "setRemoveCssSelectAll('" + aearArr[i] + "')");
      areax = areax.replace(";" + aearArr[i] + ";", ";");
    }
    var areax = areax.split(";");
    var arr = new Array();
    var str = "";
    for (var i = 0; i < areax.length; i++) {
      if (areax[i] != "") {
        str += areax[i] + ";";
      }
    }
    str = str.substring(0, (str.length - 1));
    $$("area").value = str;
    zv_SelectAreaSet();
    var strs = $$("area").value;
    var aearArrs = strs.split(";");
    var len = aearArrs.length;
    $$("area_selected").innerHTML = "共选择了" + len + "个区域";
    if (strs == "") {
      $$("area_selected").innerHTML = "请选择区域";
    }
  }

  function removeItemS(par) {
    var area = $$("area").value;
    var areax = ";" + area + ";";
    var aearArr = par.split("-");
    var start = parseInt(aearArr[0]);
    var end = parseInt(aearArr[1]);
    for (var i = start; i <= end; i++) {
      if (i < 10) {
        areax = areax.replace(";00" + i + ";", ";");
        ueppscript("intelligent_monitoring_area_hqT1", "content", "setRemoveCssSelectAll('00" + i + "')");
      }
      if (i >= 10 && i < 100) {
        areax = areax.replace(";0" + i + ";", ";");
        ueppscript("intelligent_monitoring_area_hqT1", "content", "setRemoveCssSelectAll('0" + i + "')");
      }
      areax = areax.replace(";" + i + ";", ";");
      ueppscript("intelligent_monitoring_area_hqT1", "content", "setRemoveCssSelectAll('" + i + "')");
      //aearArr
    }
    var areax = areax.split(";");
    var arr = new Array();
    var str = "";
    for (var i = 0; i < areax.length; i++) {
      if (areax[i] != "") {
        str += areax[i] + ";";
      }
    }
    str = str.substring(0, (str.length - 1));
    $$("area").value = str;
    zv_SelectAreaSet();
    var strs = $$("area").value;
    var aearArrs = strs.split(";");
    var len = aearArrs.length;
    $$("area_selected").innerHTML = "共选择了" + len + "个区域";
    if (strs == "") {
      $$("area_selected").innerHTML = "请选择区域";
    }
  }
  /**
   * 添加元素
   */
  function addItemSX(par) {
    var area = $$("area").value;
    var aearArr = par.split("/");
    for (var i = 0; i < aearArr.length; i++) {
      ueppscript("intelligent_monitoring_area_hqT1", "content", "setAddCssSelectAll('" + aearArr[i] + "')");
      area += ";" + aearArr[i];
    }
    var d1 = area.substring(0, 1);
    var d2 = area.substring((area.length - 1), area.length);
    if (d1 == ";" && d2 != ";") {
      var str = area.substring(1, area.length);
    } else if (d2 == ";" && d1 != ";") {
      var str = area.substring(0, (area.length - 1));
    } else if (d1 == ";" && d2 == ";") {
      var str = area.substring(1, (area.length - 1));
    } else {
      str = area;
    }
    $$("area").value = str;
    zv_SelectAreaSet();
    var strs = $$("area").value;
    var aearArrs = strs.split(";");
    var len = aearArrs.length;
    $$("area_selected").innerHTML = "共选择了" + len + "个区域";
    if (strs == "") {
      $$("area_selected").innerHTML = "请选择区域";
    }
  }

  function addItemS(par) {
    var area = $$("area").value;
    var aearArr = par.split("-");
    var start = parseInt(aearArr[0]);
    var end = parseInt(aearArr[1]);
    var siteIsSelected = localStorage.getItem("siteIsSelected");
    if (siteIsSelected.indexOf("SHA") != "-1") {
      //虹桥不用加0
      for (var i = start; i <= end; i++) {
        area += ";" + i;
        ueppscript("intelligent_monitoring_area_hqT1", "content", "setAddCssSelectAll('" + i + "')");
      }
    } else {
      for (var i = start; i <= end; i++) {
        if (i < 10) {
          area += ";00" + i;
          ueppscript("intelligent_monitoring_area_hqT1", "content", "setAddCssSelectAll('00" + i + "')");
        } else if (i >= 10 && i < 100) {
          area += ";0" + i;
          ueppscript("intelligent_monitoring_area_hqT1", "content", "setAddCssSelectAll('0" + i + "')");
        } else {
          area += ";" + i;
          ueppscript("intelligent_monitoring_area_hqT1", "content", "setAddCssSelectAll('" + i + "')");
        }
      }
    }
    var d1 = area.substring(0, 1);
    var d2 = area.substring((area.length - 1), area.length);
    if (d1 == ";" && d2 != ";") {
      var str = area.substring(1, area.length);
    } else if (d2 == ";" && d1 != ";") {
      var str = area.substring(0, (area.length - 1));
    } else if (d1 == ";" && d2 == ";") {
      var str = area.substring(1, (area.length - 1));
    } else {
      str = area;
    }
    $$("area").value = str;
    zv_SelectAreaSet();
    var strs = $$("area").value;
    var aearArrs = strs.split(";");
    var len = aearArrs.length;
    $$("area_selected").innerHTML = "共选择了" + len + "个区域";
    if (strs == "") {
      $$("area_selected").innerHTML = "请选择区域";
    }
  }

  function setAllarea(type, par) {
    var area = $$("area").value;
    var areax = ";" + area + ";";
    if (type == 'remove') {
      if (par.indexOf("#") > 0) {

        var arrJ = par.split("#");
        var leftStr = arrJ[0];

        var rightStr = arrJ[1];
        removeItemS(leftStr);
        removeItemS(rightStr);
      } else if (par.indexOf("/") > 0) {
        removeItemSX(par);
      } else {
        removeItemS(par);
      }
      //移除当前的par
    } else {
      if (par.indexOf("#") > 0) {

        var arrJ = par.split("#");
        var leftStr = arrJ[0];

        var rightStr = arrJ[1];
        removeItemS(leftStr);
        removeItemS(rightStr);

        addItemS(leftStr);
        addItemS(rightStr);
      } else if (par.indexOf("/") > 0) {
        removeItemSX(par);
        addItemSX(par);
      } else {
        removeItemS(par);
        addItemS(par);
      }
      //添加当前par
    }
    ueppscript("intelligent_monitoring_area_hqT1", "content", "loadAreaX()");
  }

  function setarea(id) {
    //alert("setarea:"+id);
    var isExt = "0";
    var area = $$("area").value;
    var aearArr = area.split(";");
    var arr = new Array();
    j = 0;
    for (var i = 0; i < aearArr.length; i++) {
      if (aearArr[i] == id) {
        isExt = 1;
        //break;
      } else {
        arr[j] = aearArr[i];
        j++;
      }
    }
    if (isExt == 0) {
      //添加当前传入的id
      if (area == "") {
        $$("area").value = id;
        localStorage.setItem("area_id", id);
      } else {
        $$("area").value = area + ";" + id;
        localStorage.setItem("area_id", area + ";" + id);
      }

    } else {
      //移除当前传入id
      var str = "";
      for (var i = 0; i < arr.length; i++) {
        str += arr[i] + ";";
      }
      str = str.substring(0, (str.length - 1));
      $$("area").value = str;
      localStorage.setItem("area_id", str);
    }
    //area_selected/计算选择了几个区域
    var strs = $$("area").value;
    var aearArrs = strs.split(";");
    var len = aearArrs.length;
    $$("area_selected").innerHTML = "共选择了" + len + "个区域";
    if (strs == "") {
      localStorage.setItem("AllSelectqiaowei", 0);
      $$("area_selected").innerHTML = "请选择区域";
    }
    zv_SelectAreaSet();
    ueppscript("intelligent_monitoring_area_hqT1", "content", "loadAreaX()");
  }
  window.uexOnload = function(type) {
    if (!type) {
        console.log(ceair_class_url)
      uexWindow.setBounce("0");
    }

    var extarea = localStorage.getItem("zv_SelectArea");
    localStorage.setItem("zv_SelectArea", "");

    //$$("area").value = extarea;
    var user_name = localStorage['LoginInfor'];
    var user_name = '{"username":"chengcheng1",' + '"password":"cc_890817!",' + '"domainName":"管控领域",' + '"type":"0"}';
    if (user_name != '' & user_name != 'null' & user_name != null & user_name != 'undefined' & user_name != undefined) {
      user_name = '[' + user_name + ']'
      var jsonuser = strToJson(user_name);
      var user_id = jsonuser[0].username;
      $.ajax({
        url: host_address_url + "GetUserInfo?RequestKey=" + RequestKey + "&act=GetUserSite&UID=" + user_id,
        type: "GET",
        dataType: "JSON",
        success: function(json) {
          var json = JSON.stringify(json);
          json = '[' + json + ']';
          json = strToJson(json);
          var Site = json[0].Site;
          if (Site != '' & Site != 'null' & Site != null & Site != 'undefined' & Site != undefined) {
            localStorage.setItem("manager_grade_Site", Site);
            $.ajax({
              url: "data/Category.json",
              type: "GET",
              dataType: "JSON",
              success: function(jjson) {
                //console.log(jjson);
                //alert(JSON.stringify(jjson));
                var res = jsonsql.query("select * from json.data.items where (Site=='" + Site + "' && TagName=='site')  order by OrderBy asc", jjson);

                if (res.length > 0) {
                  //select_default_val_bak(res[0].PID,'SiteID','<option value="">选择站点名称</option>',res[0].ID)
                  var ress = jsonsql.query("select * from json.data.items where (PID=='" + res[0].PID + "')  order by OrderBy asc", jjson);
                  var selectval = '<option value="">选择站点名称</option>'
                  for (var i = 0; i < ress.length; i++) {
                    var selected_id = ''
                    if (ress[i].ID == res[0].ID) {
                      selected_id = ' selected'
                    }
                    selectval += '<option value="' + ress[i].Site + '" ' + selected_id + '>' + ress[i].Name + '</option>'
                  }
                  $$("SiteID").innerHTML = selectval;
                  $$("zv_default").innerHTML = res[0].Name;
                  var pid_res = jsonsql.query("select * from json.data.items where (ID=='" + res[0].PID + "' && TagName=='site')  order by OrderBy asc", jjson);
                  $$("SiteName_default").innerHTML = pid_res[0].Name;
                  select2_val(pid_res[0].PID, 'SiteName', '<option value="">选择中心名称</option>', pid_res[0].ID)

                }
              },
              error: function(err) {
                alert(err);
              }
            });


          } else {

            select2_val('5', 'SiteName', '<option value="">选择站点名称</option>')
          }
        },
        error: function(err) {
          alert(err);
        }
      });
      $.getJSON(host_address_url + "GetUserInfo?RequestKey=" + RequestKey + "&act=AccountDomain&Account=" + user_id, function(json) {
        if (json == 0) {
          localStorage.setItem("user_json_id", user_id);
        } else {
          localStorage.setItem("user_json_id", json);
        }
      })
    } else {

      select2_val('5', 'SiteName', '<option value="">选择站点名称</option>')
    }
  }

  function OpenArea() {
    var siteIsSelected = $$("SiteName").value;
    //alert(siteIsSelected);
    //siteIsSelected = "虹桥旅服";
    localStorage.setItem("siteIsSelected", siteIsSelected);
    var area_id = localStorage.getItem("area_id"); //////////////////默认桥位
    localStorage.setItem("zv_SelectArea", area_id);
    if (siteIsSelected != "" && siteIsSelected != undefined) {
      //选择过的区域设置为空
      uexWindow.open("intelligent_monitoring_area_hqT1", 0, "intelligent_monitoring_area_hqT1.html", 0, "", "", 0);
    } else {
      $alert("请选选择中心");
    }
  }

  function LoadDataS(type) {
    //  alert(type);
    var Location = $$("area").value; /*桥位*/
    var PeriodStart = $$("PeriodStart").innerHTML; /*监控日期*/
    var PeriodEnd = $$("PeriodEnd").innerHTML;
    localStorage.setItem("backup_PeriodStart_znjk", PeriodStart);
    var SiteName = $$("SiteID").value; /*站点名*/
    if (SiteName == '') {
      $alert('请选择站点名称');
      return false;
    } else if (PeriodStart == '' || PeriodStart == '请选择监控日期') {
      $alert('请选择监控起始日期');
      return false;
    } else if (PeriodEnd == '' || PeriodEnd == '请选择监控日期') {
      $alert('请选择监控结束日期');
      return false;
    } else if (Location == '') {
      $alert('请选择区域');
      return false;
    } else {
      //PeriodStart="2014-12-09"
      PeriodStart_time = PeriodStart;
      PeriodEnd_time = PeriodEnd;

      //PeriodEnd_time = PeriodStart
      //var PeriodStart_time = zv_transdate(PeriodStart)
      //PeriodStart_time = PeriodStart_time - 8 * 60 * 60
      //PeriodStart_time = zv_detailed(PeriodStart_time)
      localStorage.setItem("SiteName", SiteName);
      if (SiteName == 'SHAACC') {
        SiteName = "WorkBridgeWebServiceSHALOAD;WorkBridgeWebServiceSHAT1LUG;WorkBridgeWebServiceSHAT2LUG;WorkBridgeWebServiceSHAPAXDOM2;WorkBridgeWebServiceSHAPAXINTER;WorkBridgeWebServiceSHARAMP;WorkBridgeWebServiceSHAWB"

      } else if (SiteName == 'PVGHCC') {
        SiteName =
          "WorkBridgeWebServicePVGT1LOAD;WorkBridgeWebServicePVGT2LOAD;WorkBridgeWebServicePVGCGOLOAD;WorkBridgeWebServicePVGT1LUG;WorkBridgeWebServicePVGT2LUG;WorkBridgeWebServicePVGFOREIGNPAX2;WorkBridgeWebServicePVGFOREIGNPAX1;WorkBridgeWebServicePVGDEPT12;WorkBridgeWebServicePVGRAMPT2;WorkBridgeWebServicePVGRAMPT1;WorkBridgeWebServicePVGWB"
      } else {
        SiteName = "WorkBridgeWebService" + SiteName
      }
      if (type != 1) {
        Loading(0);
      }
      //var wsdl = intelligent_monitoring_url;
      var wsdl = "http://172.17.61.136/PersonalCenterWebService/PersonalCenterWebService.asmx?wsdl";
      var nameSpace = intelligent_monitoring_nameSpace;
      var paras = "PeriodStart|PeriodEnd|SiteName|Location";
      var values = PeriodStart_time + "|" + PeriodEnd_time + '|' + SiteName + '|' + Location;
      //console.log(PeriodStart_time + "===" + PeriodEnd_time + "==" + SiteName + "==" + Location);

      localStorage.setItem("SITENAMEzyh", SiteName);
      //var method = intelligent_monitoring_function;
      var method = "PersonalCenterGetOperationByLocation";
      if (type == 1) {
        setLocalJosnPage(wsdl, nameSpace, paras, values, method, "intelligent_monitoring_view", "monitoring_list");
      } else {

        localStorage.setItem("monitoring_judge", "") //超时
        $.ajax({
          url: ceair_class_url,
          type: "GET",
          dataType: "JSON",
          success: function(ajson) {
            var jsonStr = JSON.stringify(ajson);
            //alert("522"+jsonStr);
            localStorage.setItem("Class_Data", jsonStr);
            localStorage.setItem("zvData", ''); //设置数据为空
            monitoringJosn(wsdl, nameSpace, paras, values, method, "intelligent_monitoring_view", "intelligent_monitoring_view.html","","intelligent");

            setTimeout('monitor_timeout()', 120000) //两分钟后执行
          }
        });
      }
    }
  }

  function monitor_timeout() {
    var zvData = localStorage.getItem("zvData")
    if (zvData == '' || zvData == 'undefined' || zvData == undefined || zvData == null) {
      localStorage.setItem("monitoring_judge", "1") //超时
      $alert("查询超时")
      Loading(-1);
    }
  }
</script>

</html>
